<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    *{
      margin:0;
      padding:0;
    }
    #app{
      width:100%;
      height:800px;
      background-color: aquamarine;
    }
    #lazyimg{
      border:4px red solid;
    }
  </style>
</head>
<body>
  <div id="app">

  </div>
  <img src="" alt="" srcset="">
  <img id="lazyimg" data-xxx="false" src="" data-src="https://sqimg.qq.com/mapp/im_qq_com/pc-feture.png" alt="tupian" title="ererere">
  <script>
    const lazyimg=document.getElementById('lazyimg')
    window.onscroll=function(e){
      console.log('document.documentElement.clientHeight',document.documentElement.clientHeight);
      console.log('scrollY',window.scrollY,'innerHeight',window.innerHeight);
      console.log('lazyimg.offsetTop',lazyimg.offsetTop,'clientTop',lazyimg.clientTop,'lazyimg.scrollTop',lazyimg.scrollTop,'lazyimg.clientHeight',lazyimg.clientHeight);
      console.log('lazyimg.xxx',lazyimg.dataset.xxx);
      console.log('------------------------------------------');
      if (window.scrollY+window.innerHeight>lazyimg.offsetTop+1 && lazyimg.dataset.xxx=='false') {
        console.log('加载加载');
        lazyimg.src= lazyimg.dataset.src
        lazyimg.dataset.xxx='true'
      }
      // lazyimg.get
    }
  </script>
</body>
</html>